package org.vt.scheduleapp;

import java.util.ArrayList;

import android.app.AlertDialog;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.GestureDetector;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;


@SuppressWarnings("rawtypes")
public class MapItemizedOverlay extends ItemizedOverlay  {

	private ArrayList<OverlayItem> mapOverlays = new ArrayList<OverlayItem>();
	Context mapcontext;
	GestureDetector.SimpleOnGestureListener gd= new GestureDetector.SimpleOnGestureListener();
	/**
	 * @param defaultMarker
	 */
	public MapItemizedOverlay(Drawable defaultMarker) {
		super(boundCenterBottom(defaultMarker));
	}

	public MapItemizedOverlay(Drawable defaultMarker, Context context) {
		super(boundCenterBottom(defaultMarker));
		mapcontext = context;
	}

	
	@Override
	protected OverlayItem createItem(int overlayIndex) {
		return mapOverlays.get(overlayIndex);
	}

	@Override
	public int size() {
		return mapOverlays.size();
	}

	public void addOverlay(OverlayItem OI) {
		mapOverlays.add(OI);
		populate();
		
	}
	@Override
	protected boolean onTap(int index) {
		OverlayItem Oitem = mapOverlays.get(index);
		AlertDialog.Builder dialog = new AlertDialog.Builder(mapcontext);
		dialog.setTitle(Oitem.getTitle());
		dialog.setMessage(Oitem.getSnippet());
		dialog.show();
		return true;
		
	}
}